Typical video codecs are based on motion compensated prediction and prediction error coding. Motion compensated prediction is obtained by analyzing and coding motion between video frames and reconstructing image segments using the motion information. Prediction error coding is used to code the difference between motion compensated image segments and corresponding segments in the original image. The accuracy of prediction error coding can be adjusted depending on the available bandwidth and required quality of the coded video. In a typical Discrete Cosine Transform (DCT) based system this is done by varying the quantizer parameter (QP) used in quantizing the DCT coefficients to specific accuracy.
Coding systems, in general, provide a set of parameters to represent the coded signals. These parameters are entropy coded and sent to the decoder for decoding and reconstruction of the coded signal. To improve the compression performance of the entropy coder, the parameters are often predicted from the information available for both encoder and decoder. By doing this, the entropy coder needs to code only small variance differences between the actual parameter values and the predicted ones leading into coding gain. The encoding process is illustrated in FIG. 1.
As shown in FIG. 1, input signal indicative of an image segment in a video sequence is provided to a parameter creation block, where a set of parameters representing the input signal are created. Based on the parameters created by the parameter creation block, a parameter prediction block is used to provide a set parameters represented a motion-compensated prediction image segment. A subtracting module is then used to compute the difference between the actual parameters and the predicted ones for providing the parameter differences p. The parameter differences p are encoded by an entropy coder to provide a set of codewords, so as to allow a decoder to reconstruct the input signal from the codewords.
In a typical case, the entropy coder assumes that the most probable parameter difference is zero and the small differences are always more probable than larger deviations from the predictor. Thus, the entropy coder can map the parameter differences to codeword indexes in the order of descending probability using the formula below.c=2abs(p)−sign(p),  (1)where abs(p) denotes the absolute value of the parameter difference p, sign(p) is the sign of the parameter difference p, and c is the codeword index. More specifically,
      sign    ⁡          (      p      )        =      {                                        +            1                                    for                                      p            >            0                                                0                          for                                      p            ≤            0                              
It can be seen that, in the decoder, the parameter difference p can be easily reconstructed by inverse mapping as follows:p=isign(c)(c+odd(c))/2,  (2)where isign(c) is determined by whether c is an even number or an odd number. More specifically,
            i      ⁢      sign        ⁢                  ⁢          (      c      )        =      {                                        -            1                                    for                                      c            ⁢                                                  ⁢            even                                                            +            1                                    for                                      other            ⁢                                                  ⁢                          c              .                                          odd(c) is 1 if c is odd and 0 otherwise.
Using these equations, the mapping of parameter differences p to codeword indexes c looks like:
p. . .−6−5−4−3−2−10123456. . .c. . .1210864201357911. . .Now, the codeword indexes are mapped in descending order of probability and can be efficiently coded, for example, using Exponential Golomb Codes.
When the coding parameters are within a limited range, the result is undesirable. For example, if the range of the parameter (or parameter difference as discussed above) p can only have values between −6 and 1, the mapping of p to codeword indexes c using Equation 1 would yield
p−6−5−4−3−2−101c1210864201This mapping leads to significant reduction in compression performance, since codeword indexes 3, 5, 7, . . . are never used.
Prior art solution to this coding inefficiency is to use straightforward modulo arithmetic or circular mapping method to map the unused indexes to valid ones. This approach maps the overflowing indexes (3, 5 and 7 in the example below) to the other end of the parameter space. As such, the indexes 12, 10 and 8 are mapped to 3, 5 and 7, respectively.
The advantage of this method is the straightforward calculation, but on the other hand, it leads to suboptimal performance since low probability parameters from the other end of the parameter space are mapped to small (i.e. high probability) codeword indexes, such as 3 and 5. Table below demonstrates this kind of mapping when parameters have valid values from −6 to 1.
p−6−5−4−3−2−101c35764201
As such, the use of Exponential Golomb Codes for coding may not be efficient.
Thus, it is advantageous and desirable to provide a coding method and system wherein the mapping from the parameter differences or the parameters to codeword indexes is optimal, regardless of the limited range of the parameter differences or parameters.